package com.ddyx.rest;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.ddyx.service.IEmployeService;

@Controller
@RequestMapping("/employe")
public class EmployeController {
	
	@Resource
	IEmployeService employeService;
	
	/**
	 * 添加店员
	 * @param storeId
	 * @param employeName
	 * @param mobile
	 * @param email
	 * @return
	 */
	@RequestMapping(value = "add", method = RequestMethod.POST, consumes = "application/json")
	public @ResponseBody String addEmploye(@RequestBody JSONObject object){
		return employeService.addEmploye(object);
	}
	
	/**
	 * 修改店员信息
	 * @param employeId
	 * @param employeName
	 * @param mobile
	 * @param email
	 * @return
	 */
	@RequestMapping(value = "edit", method = RequestMethod.POST, consumes = "application/json")
	public @ResponseBody String editStore(@RequestBody JSONObject object){
		return employeService.editEmploye(object)	;
	}
	
	@RequestMapping(params = "cmd=listEmploye", method = RequestMethod.GET)
	public @ResponseBody String selectByStoreName(@RequestParam(value="page",defaultValue="1") int page
			,@RequestParam(value="size",defaultValue="20") int size
			,@RequestParam(value="employeName",defaultValue="")String employeName) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("page", page);
		map.put("size", size);
		map.put("employeName", employeName);
		return employeService.selectEmployeBy(map);
	}
}
